Michael Ippolito 4/28/2022
# Load modules
import plotly.express as px
#from IPython.display import display, HTML
import plotly.io as pio
# Set plotly rendered
#pio.renderers.default = 'notebook_connected'
pio.renderers.default = 'notebook'
#print(pio.renderers)
#js = '<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js" integrity="sha512-c3Nl8+7g4LMSTdrm621y7kf9v3SDPnhxLNhcjFJbKECVnmZHTdo+IRO05sNLTH/D3vA6u1X32ehoLC7WFVdheg==" crossorigin="anonymous"></script>'
#display(HTML(js))
# Load data
df = px.data.tips()
df.head()
| total_bill | tip | sex | smoker | day | time | size | |
|---|---|---|---|---|---|---|---|
| 0 | 16.99 | 1.01 | Female | No | Sun | Dinner | 2 |
| 1 | 10.34 | 1.66 | Male | No | Sun | Dinner | 3 |
| 2 | 21.01 | 3.50 | Male | No | Sun | Dinner | 3 |
| 3 | 23.68 | 3.31 | Male | No | Sun | Dinner | 2 |
| 4 | 24.59 | 3.61 | Female | No | Sun | Dinner | 4 |

# Recreate bar plot 1
fig1 = px.bar(df, x="sex", y="total_bill", color="smoker", barmode="group")
fig1.show()

# Recreate bar plot 2
fig2 = px.bar(df, x="sex", y="total_bill", color="day", barmode="group")
fig2.show()

# Recreate scatter plot 1
fig3 = px.scatter(df, x="total_bill", y="tip", color="sex", facet_col="smoker")
fig3.show()

# Recreate scatter plot 2
fig4 = px.scatter(df, x="total_bill", y="tip", color="sex", facet_col="smoker", trendline="ols")
fig4.show()

# Recreate scatter plot 3
fig5 = px.scatter(df, x="total_bill", y="tip", facet_col="day", facet_row="time",
category_orders={'day': ['Thur', 'Fri', 'Sat', 'Sun'], 'time': ['Dinner', 'Lunch']})
fig5.show()

# Recreate histogram 1
fig6 = px.histogram(df, x="tip", marginal="rug")
fig6.show()

# Recreate boxplot 1
fig7 = px.box(df, y="tip", color="smoker")
fig7.show()